package com.night.test;

import com.night.annotation.Autowired;
import com.night.annotation.Component;
import com.night.annotation.Transactional;
import com.night.jdbc.JdbcTemplate;

/**
 * @Author: chen yang
 * @Date: 2024/12/7 10:30
 */
@Component
@Transactional
public class UserService {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    public void update(String username, String password) {
        String updateSql = "update t_user set password = ? where username = ?";
        jdbcTemplate.update(updateSql, password, username);

        if (username.equals("tony")) {
            throw new RuntimeException("cannot update tony");
        }
        System.out.println("success");
    }
}
